set nocompatible
source $VIMRUNTIME/vimrc_example.vim
"source $VIMRUNTIME/mswin.vim
"behave mswin

set diffexpr=MyDiff()
function! MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  let eq = ''
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      let cmd = '""' . $VIMRUNTIME . '\diff"'
      let eq = '"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction

"""""""""""自定义开始""""""""""""

"内码使用utf8，优先以utf8尝试解码
set encoding=utf8
set fencs=utf8,cp936

"通用的一些样式
sy on
colorscheme wf
set laststatus=2
set nobk
set statusline=%F\ [%{&fenc}\ %{&ff}\ %l/%L]
"缩进使用的空白数
set shiftwidth=4
"文件中的tab代表的空格数
set tabstop=4
"插入tab时使用合适数量的空格
"set noexpandtab
set expandtab
"开启新行时使用智能自动缩进
set autoindent
set foldmethod=marker
set number
"set cursorline

"下面这句是为了让较长的行显示
set display=lastline

map <C-tab> <C-W>w

"快速设置文件类型为html
map		<F10>	:set ft=html<CR>

"配置TOhtml生成的代码格式
let use_xhtml = 1
let html_use_css = 1
"是否需要强制显示行号
"let html_number_lines = 1


"配置netrw插件更好的浏览目录
let g:netrw_altv = 1
let g:netrw_winsize = 23
let g:netrw_liststyle = 3
map     <F9>    <C-W>c
map     <F8>    :Vexplore<CR>

"编辑html同时设置js、css类型，方便snipptMate插件工作
autocmd BufNewFile,BufRead *.html,*.tpl,*.htm set filetype=html.javascript.css
autocmd BufNewFile,BufRead *.php set filetype=php,html.javascript.css

"编辑文本文件时，tab不要变成空格
autocmd! BufNewFile,BufRead *.txt,*.text,*.data set noexpandtab

"acp插件调用snipptMate定义的东东
let g:acp_behaviorSnipmateLength = 1

"设置自动完成词典
autocmd Filetype javascript set dictionary+=$vim/vimfiles/directory/tangram
autocmd Filetype javascript,html,html set dictionary+=$vim/vimfiles/directory/javascript
autocmd Filetype php set dictionary+=$vim/vimfiles/directory/php

"每次编辑完.vimrc文件时立刻加载
autocmd! bufwritepost *vimrc :source $MYVIMRC

"<F12>快速编辑.vimrc
map <F12> :e $MYVIMRC<CR>

"取消鼠标支持，这样终端可以复制文本
set mouse=


"""""""""" GUI设置 """"""""""""
if has('gui_running')
	set guioptions=cr
endif



""""""""" windows gvim设置 """"""""
if has('win32') || has('win64')

	"设置交换文件路径
	set dir=c:/tmp

	"按F5调用系统默认程序打开文件
	nnoremap <silent> <F5> :let old_reg=@"<CR>:let @"=substitute(expand("%:p"), "/", "\\", "g")<CR>:silent!!cmd /cstart <C-R><C-R>"<CR><CR>:let @"=old_reg<CR>
	nmap <F6> :update<CR>:silent !start f:\progra~1\intern~1\iexplore.exe file://%:p<CR>
	map <C-tab> <C-W>w
	
	"最大化 字体
	au GUIEnter * simalt ~x
	set guifont=Consolas:h11
    
    "防止菜单发生乱码
    set langmenu=zh_CN
    let $LANG = 'zh_CN.UTF-8'
    source $VIMRUNTIME/delmenu.vim
    source $VIMRUNTIME/menu.vim

endif
